def slurper = new XmlSlurper().parseText(new URL("http://www.berkeleybop.org/ontologies/obo-all/ontology_index.xml").getText())

def prefix = "http://www.berkeleybop.org/ontologies/"
slurper.ont.each { ont ->
  String namespace = ont.namespace
  ont.export.each { exp ->
    if (exp.@format == "obo") {
      String path = exp.@path
      if (path.length()>1 && namespace?.length()>0) {
	def downloadUrl = new URL(prefix+path)
	def file = new FileOutputStream(new File("data/$namespace"))
	def out = new BufferedOutputStream(file)
	out << downloadUrl.openStream()
	out.close()
      }
    }
  }
}